package com.wangzaiplus.test.juc.thread;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;

/**
 * @ClassName Demo01
 * @Description: TODO
 * @Author wgc
 * @Date 2020/06/28 10:17
 * @Version V1.0
 **/
@Slf4j
public class Demo01 {
    public static void main(String[] args) throws InterruptedException {
       Thread thread1=new Thread(){
           @Override
           public void run() {
               log.info("--start--");
               boolean flag=true;
                while(flag){
                    ;
                }
               log.info("--end--");
           }
       };
        thread1.setName("thread1");
        thread1.start();

        //当前线程休眠1秒
        TimeUnit.SECONDS.sleep(1);

        thread1.stop();


        //输出线程thread1的状态
         log.info("{}",thread1.getState());
        //当前线程休眠1秒
        TimeUnit.SECONDS.sleep(1);

        //输出线程thread1的状态
        log.info("{}",thread1.getState());
    }
}
